package com.nan.buy.service.Impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.nan.buy.common.UUIDUtil;
import com.nan.buy.dao.AdminMapper;
import com.nan.buy.model.Admin;
import com.nan.buy.service.AdminService;

@Service
public class AdminServiceImpl implements AdminService {

	@Resource
	private AdminMapper adminMapper;
	
	@Override
	public List<Admin> searchAdmins() {
		return adminMapper.selectAdmins();
	}

	@Override
	public int updateAdmin(Admin admin) {
		return adminMapper.updateByPrimaryKeySelective(admin);
	}

	@Override
	public int delAdmin(String aId) {
		return adminMapper.deleteByPrimaryKey(aId);
	}

	@Override
	public List<Admin> searchByName(String aName) {
		Map<String,Object> param=new HashMap<String, Object>();
		param.put("aName", aName);
		return adminMapper.searchByName(param);
	}

	@Override
	public int addAdmin(Admin admin) {
		admin.setaId(UUIDUtil.getUUID());
		return adminMapper.insertSelective(admin);
	}

}
